<template>
<!-- 登录页面 -->
  <div class="frame">
    <el-form action="" :model="form">
      <div class="frame_conter">
        <div class="frame_conter_left">
          <el-carousel class="frame_conter_left_img" height="599px">
            <el-carousel-item v-for="(item, index) in item" :key="index">
              <img class="carousel_img" :src="item.url" />
            </el-carousel-item>
          </el-carousel>
        </div>
        <div class="frame_conter_right">
          <div class="ct">
            <img
              class="frame_conter_right_logo"
              src="../assets/logo.png"
              alt=""
            />
          </div>
          <h1 class="frame_conter_right_title">
            盛邦升华信息管理系统
          </h1>
          <el-form-item class="us" label="用户名：">
            <el-input
              placeholder="请输入用户名"
              v-model="form.username"
            ></el-input>
          </el-form-item>
          <el-form-item class="pas" label="密码：">
            <el-input
              placeholder="请输入密码"
              v-model="form.password"
              show-password
            ></el-input>
            <el-button
              id="sign"
              type="primary"
              @click="sign"
              :loading="loadingbut"
              >登 录</el-button>
          </el-form-item>
          <p class="title3">———————学好硬本领，赢在软实力———————</p>
        </div>
      </div>
    </el-form>
  </div>
</template>

<style scoped>
.bottom {
  float: bottom;
}
.frame {
  width: 100%;
  height: 600px;
  position: fixed;
  top: 50%;
  margin-top: -300px
}
.frame_conter {
  height: 600px;
  margin: auto 14.5%;
  border: 2px #dcdcdc solid;
  border-radius: 15px;
  box-shadow: 5px 5px 5px #c4c3c3;
}
.frame_conter_left {
  float: left;
  width: 60%;
  height: 600px;
  border-radius: 15px;
}
.frame_conter_left_img {
  border-radius: 15px 0px 0px 15px;
  margin-top: -1px;
  margin-left: -1px;
}
.carousel_img {
  width: 100%;
  height: 100%;
}

.frame_conter_right {
  width: 40%;
  height: 600px;
  float: right;
}
.frame_conter_right_logo {
  width: 50px;
  height: 50px;
}
.ct {
  /* width: 50px; */
  height: 50px;
  padding-top: 74px;
  padding-left: 8%;
}
.frame_conter_right_title {
    margin-top: 2px;
    /* font-size: xx-large; */
    text-align: center;
    font-family: cursive;
}
.us {
  width: 81%;
  margin-left: 11%;
  margin-top: 50px;
  font-size: 27px;
}
.pas {
  width: 81%;
  margin-left: 11%;
  margin-top: 30px;
  font-size: 27px;
}
#sign {
  width: 100%;
  height: 45px;
  /* margin-left: 22px; */
  margin-top: 50px;
}
.title3 {
    font-size: 15px;
    margin-top: 12%;
    text-align: center;
    /* margin-left: 23px; */
    color: rgb(160, 158, 158);
}
/* 响应式 */
@media screen and (max-width:1650px){
  .frame_conter_right_title {
    font-size: 24px;
  }
  .frame {
    width: 1650px;
    height: 600px;
  }
}
</style>

<script>
export default {
  data() {
    return {
      loadingbut: false, //审核提交加载中
      // 轮播图
      item: [
        {
          url: require("../assets/carousel1.jpg"),
        },
        {
          url: require("../assets/carousel2.jpg"),
        },
        {
          url: require("../assets/carousel3.jpg"),
        },
        {
          url: require("../assets/carousel4.jpg"),
        },
        {
          url: require("../assets/carousel5.jpg"),
        },
      ],
      // 用户名密码存放
      form: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    // 登录方法
    sign() {
      this.loadingbut = true;
      const _ = this.$http  // 调用请求头
      _.post(`/api/login`, this.form).then((res) => {
        this.loadingbut = false
        console.log(res.data)
        if (res.data.code === 2000) {
          localStorage.setItem('access_token',res.data.access_token)
          console.log(localStorage.getItem('access_token'))
          this.$router.push("/");
          setTimeout(()=>{
            location.reload();
            // console.log(res.data)
            localStorage.setItem('Yhzt',res.data.username.rolename_name)
          },100)
        } else {
          this.$message.error("请输入正确的用户名或密码");
        }
      });
    },
  },
};
</script>
